<template>
	<div style="padding:0px;">
		<el-form :model="dialogForm"  ref="dialogForm" :label-width="formLabelWidth" >
			<el-card class="box-card">
			    <div slot="header" class="clearfix">
			        <span style="line-height: 30px;">订单信息</span>
			    </div>
			    <div  class="text item">
			    	<el-form-item label="订单号"  >
				        <el-input v-model="dialogForm.orderNumber" auto-complete="off" disabled ></el-input>
				    </el-form-item>	
				    <el-form-item label="汽车车型"   >
				        <el-input  v-model="dialogForm.specificationName" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				    <el-form-item label="汽车数量"  prop="amount">
				        <el-input  type="tel" :maxlength="9" v-model.number="dialogForm.amount" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				    
				    <el-form-item   label="购车总价格"   prop="totalPrice" class="currency">
				    	<el-input   v-model="dialogForm.totalPrice" @blur="FormatTwo('totalPrice')" :maxlength="11"  auto-complete="off" disabled></el-input> 
				    	<span class="convertCurrency">{{dialogForm.totalPrice|convertCurrency}}</span>
				    </el-form-item>
				    <el-form-item label="垫资金额"   prop="paymentAmount" class="currency">
				    	<el-input   v-model="dialogForm.paymentAmount" @blur="FormatTwo('paymentAmount')" :maxlength="11" auto-complete="off" disabled></el-input>
				    	<span class="convertCurrency">{{dialogForm.paymentAmount|convertCurrency}}</span>
				    </el-form-item>
				    <el-form-item label="定金金额"   prop="earnest" class="currency">
				    	<el-input  v-model="dialogForm.earnest" @blur="FormatTwo('earnest')"  :maxlength="11" auto-complete="off" disabled></el-input>
				    	<span class="convertCurrency">{{dialogForm.earnest|convertCurrency}}</span>
				    </el-form-item>
				    <el-form-item label="保证金金额"   prop="deposit" class="currency">
				    	<el-input  :value="(((this.dialogForm.totalPrice-0) - (this.dialogForm.paymentAmount-0) - (this.dialogForm.earnest-0))||0).toFixed(2)"  disabled></el-input>
				    	<span class="convertCurrency">{{((this.dialogForm.totalPrice-0) - (this.dialogForm.paymentAmount-0) - (this.dialogForm.earnest-0)).toFixed(2)|convertCurrency}}</span>
				    </el-form-item>
				    <el-form-item label="审核备注"  v-if="!isApply">
				      <el-input type="textarea" :rows=3 v-model="dialogForm.remark" auto-complete="off" :maxlength="200" disabled ></el-input>
				    </el-form-item>	
				</div>
			</el-card>
			
		    <el-card class="box-card" style="margin-top:15px;">
			    <div slot="header" class="clearfix">
			        <span style="line-height: 30px;">退单信息</span>
			    </div>
			    <div  class="text item">
				    <el-form-item label="退单理由"  >
				      <el-input type="textarea" :rows=3 v-model="dialogForm.remark" auto-complete="off" :maxlength="200" :disabled="!dialogSendData.isAdd"></el-input>
				    </el-form-item>	
			    </div>
			</el-card>
		</el-form>
		<div style="text-align:right;margin-top:15px;">
			 <el-button @click="returnBack">返 回</el-button>
			 <el-button v-if="dialogSendData.isAdd" type="primary" @click="submitConfirmForm('dialogForm')">提 交</el-button>
		</div>
	</div>
</template>
<script  >
    import agentHttp from '@/utils/agentHttp.js';
	export default{ 
		created(){  
		   
        },
		data(){
			return{
				dialogForm:{
				},
				formLabelWidth:'170px', 
			}
		},props:[
		    'dialogSendData','tableData','carOrderId','isApply'
		    ]
		,methods:{	
			returnBack (){
				this.dialogSendData.dialogFormVisible=false; 
			},
			submitConfirmForm(formName){ 
            	this.$refs[formName].validate((valid) => {
		          if (valid) {
		          	this.submitOrder();
		          } else {
		          	this.$nextTick(()=>{
		          	   setTimeout(()=>{this.$message.warning(document.getElementsByClassName('el-form-item__error')[0].innerText);},200) 
		               return false;
		            })
		          }
		        });
			},
			submitOrder(){	
				agentHttp.postJson('adminApi/admin/car_order/first_audit_order/temporary_sumbit',this.dialogForm).then((data)=>{
		            if(data.success){  
		            	this.$emit('refreshTableData');
		            	this.dialogSendData.dialogFormVisible=false; 
		            	this.$message.success(data.data||"提交成功");
		            } 
		        }) 
		    }
		}
	};
		 
</script>